﻿using ReflectionStudio.Components.UserControls;
using ReflectionStudio.Core.Events;
using System;
using System.ComponentModel;
using System.Data;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Collections.Generic;
using System.Threading;
using System.Diagnostics;
namespace WPFExcelReport
{
    public partial class JLTSW
    {
        ApplicationBase app
        {
            get
            {
                return ApplicationBase.Instance;
            }
        }
        VJLTSW vm;
        public JLTSW()
        {
            vm = new VJLTSW();
            DataContext = vm;
            InitializeComponent();
            this.Name = "织厂评定"; 
            SetUp();
        }

        private void SetUp()
        {
            //默认注释随客户不同而不同，所以放在这里
           //根据01-，02-，03-等等对备注类型进行分类。分类方法可以依据客户不同自己定义，主要用于报表和显示。例如01如果代表成份，则可以在打印时处理。保存在TXTKON表的某个自duang
            List<string> deftxt = new List<string>();
            deftxt.Add("01-备注:");
             cMaster.DEFWSTXT = deftxt;
            deftxt = new List<string>();
            deftxt.Add("00-please type your remark after remove this:");
            cMaster.DEFTXT = deftxt;
            cMaster.VALBTYP = "TSTVALB";
            cMaster.IsExtProd = true;
            if (app.User == "JLTV    ")
            {
                cMaster.ART = "S5-135";
                cMaster.IsEdit = true;
            }
            /*
            {
                System.IO.Directory.CreateDirectory("T:\\IntexReport");
            }
            if (!System.IO.Directory.Exists("T:\\IntexReport\\Images"))
            {
                System.IO.Directory.CreateDirectory("T:\\IntexReport\\Images");
            }*/
            if (!System.IO.Directory.Exists("T:"))
            {
                /*string COMM = "";
                COMM = "net use T: //192.168.1.16/IntexReport Tissu!@# /USER:administrator ";
                RunCmd(COMM);*/
                //MessageBox.Show("请先建立T盘映射，就看到图片！");
            }
            cMaster.IMAGEPATH = "T:\\Images";
        }
        public static string RunCmd(string command)
        {
            Process p = new Process();
            p.StartInfo.WorkingDirectory = "c:\\";
            p.StartInfo.FileName = "cmd.exe"; //程序名
            p.StartInfo.Arguments = "/c " + command;
            p.StartInfo.UseShellExecute = false;
            p.StartInfo.RedirectStandardInput = true;
            p.StartInfo.RedirectStandardOutput = true;
            p.StartInfo.RedirectStandardError = true; //重定向错误输出
            p.StartInfo.CreateNoWindow = true; //不显示窗口

            p.Start();
            return p.StandardOutput.ReadToEnd(); 
        }
        

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            

        }  
    }
}
